<?php
/**
 * Created by Wang.
 * User: nango
 * Date: 2016-06-03
 * Time: 11:46
 * 解析URL
 */

namespace Wang\Core;


class ParseUrl
{

    static function PUrl(){
        $oper = parseUrlToArr();
        $moudle = ucfirst($oper[0]);
        $controller = ucfirst($oper[1]);
        $action = ucfirst($oper[2]);
        $path = "App\\$moudle\\Controller\\$controller";

        //验证操作合法性
        if(!is_dir(__APP__.$moudle)) {
            $controller = new Controller();
            $controller->error('模块不存在！');
            exit;
            //防止继续执行 直接退出
        }
        if(!file_exists(__APP__.$moudle.'/Controller/'.$controller.'.class.php')){
            $controller = new Controller();
            $controller->error('不存在的控制器！');
            exit;
        }

        $object = new $path;
        $object->$action();
    }
}